package com.aurora.supermarket.splash;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.aurora.supermarket.MainActivity;
import com.aurora.supermarket.R;
import com.aurora.supermarket.base.AppBaseActivity;
import com.aurora.supermarket.base.BasePresenter;
import com.aurora.supermarket.util.AppPreference;
import com.bumptech.glide.Glide;

import java.util.Random;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/3/23.
 * 启动页
 */

public class SplashActivity extends AppBaseActivity {


    @BindView(R.id.imageView)
    ImageView imageView;
    Integer[] ImgResIds = new Integer[]{R.drawable.splash};
    boolean isFirstLaunch;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        setFullScreen();
        super.onCreate(savedInstanceState);
        initToolbar(false, "", false);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        Random random = new Random();

        Glide.with(this)
                .load(ImgResIds[0])
                .into(imageView);

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                boolean isFirstLaunch = AppPreference.getAppPreference().getBoolean(AppPreference.IS_FIRST_LAUNCH,true);


                    startActivity(new Intent(SplashActivity.this,MainActivity.class));
                    finish();

            }
        }).start();
    }

    @Override
    public BasePresenter attach() {
        return null;
    }
}
